﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace web.httpfetch
{
    class TagAttribute
    {
        private string attributeName;
        private string attributeValue;

        public string AttributeName
        {
            get { return attributeName; }
            set { attributeName = value; }
        }

        public string AttributeValue
        {
            get { return attributeValue; }
            set { attributeValue = value; }
        }
    }
    class Tags
    {
        #region Private Member

        private string tagsName;

        //One Tag Only have one ParentTags
        private Tags parentTags;

        //One Tag may have lots of child tags
        private List<Tags> childTags;
        
        //Tags will have lots of attributes, this may not be parsed at begining.
        private List<TagAttribute> attributes;
        //tags has some content between <>content</ >
        private string tagsContent;

        //tags type is <> or < />
        private TagsType type;

        //If tag is <../>, the tagstart and pairtagstart is same
        private int tagStart;  //content[tagStart]='<';
        private int tagEnd;    //content[tagEnd]='>';
        private int pairtagStart;
        private int pairtagEnd;

        #endregion

        /// <summary>
        /// public Constractor
        /// </summary>
        public Tags()
        {
            childTags = new List<Tags>();
            type = TagsType.DoubleCloseTags;//use double close Tags as default.
        }

        #region Public Property
        /// <summary>
        /// 
        /// </summary>
        public string TagsName
        {
            get { return tagsName; }
            set { tagsName = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public string TagsContent
        {
            get { return tagsContent; }
            set { tagsContent = value; }
        }
        
        /// <summary>
        /// 
        /// </summary>
        public TagsType Type
        {
            get { return type; }
            set { type = value; }
        }

        public List<Tags> ChildTags
        {
            get { return childTags; }
            set { childTags = value; }
        }

        #endregion

        public void AddChildTag(Tags t)
        {
            childTags.Add(t);
        }
    }
}
